# -*- mode:Makefile -*-
include ../Makefile.common
LANG=perl
CXXFLAGS+=-I.. -I../ext
BASEDIR=..
DISTCLEANOBJ+=$(MODULE).bs Makefile.PL Makefile.perl blib pm_to_blib
CLEANOBJ+=$(DISTCLEANOBJ) $(MODULE).pm
TARGET=_$(MODULE).so
PREFIX=/usr/local
do:$(TARGET)
$(TARGET): $(MODULE)_wrap.cpp Makefile.perl
	$(MAKE) -f Makefile.perl
Makefile.perl: Makefile.PL	
	perl Makefile.PL
$(MODULE)_wrap.cpp: $(BASEDIR)/$(MODULE).i
	$(SWIG) -c++ -$(LANG) -o $@ $(BASEDIR)/$(MODULE).i
Makefile.PL: Makefile
	echo "use ExtUtils::MakeMaker;" > $@
	echo "WriteMakefile(" >> $@
	echo "    'PREFIX' => '${PREFIX}'," >> $@
	echo "    'NAME' => '${MODULE}'," >> $@
	echo "    'INC' => '${QUOTE_CXXFLAGS}'," >> $@
	echo "    'LIBS' => '${LDFLAGS}'," >> $@
	echo "    'CC' => '${CXX}'," >> $@
	echo "    'LD'=>'${CXX} -shared'," >> $@
	echo "    'OBJECT' => '${MODULE}_wrap.o ${BASEDIR}/${MODULE}.o ${BASEDIR}/${MODULE}Plugin.o'," >> $@
	echo "    'MAKEFILE' => 'Makefile.perl'," >> $@
	echo ");" >> $@
	echo "" >> $@
install: Makefile.perl
	$(MAKE) -f Makefile.perl install
